import fetch from 'common/src/utils/fetch'
const api_name = 'api/welcomeservice'
const group_name = 'tutorList'
const group_name_two = 'tutorStudent'

/**
 *通过teacherCode 查找教师学堂或专业
 */
function findTutorListByVo(type, code) {
  return fetch({
    url: `${api_name}/${group_name}/list/${type}/${code}`,
    method: 'get'
  });
}


/**
 *通过teacherCode 查找教师信息
 */
function findTeacherByCode(code) {
  return fetch({
    url: '/api/baseresservice/teacher/findTeacherBycode?code=' + code,
    method: 'get'
  });
}


/**
 *新增导师库
 */
function addTutor(data) {
  return fetch({
    url: `${api_name}/${group_name}`,
    method: 'post',
    data: data
  });
}


/**
 *通过Id查找导师
 */
function findTutorById(id) {
  return fetch({
    url: `${api_name}/${group_name}/${id}`,
    method: 'get'
  });
}


/**
 *编辑导师库
 */
function editTutor(data) {
  return fetch({
    url: `${api_name}/${group_name}`,
    method: 'put',
    data: data
  });
}

/**
 *查询图片
 */
function findPicture(imgUrl) {
  return fetch({
    url: '/api/commonservice/obsfile/downloadimage?objectkey=' + imgUrl,
    method: 'get'
  });
}

function findTutor(data) {
  return fetch({
    url: `${api_name}/${group_name}/list`,
    method: 'post',
    data: data
  });
}

function findTutorGroup(data) {
  return fetch({
    url: `${api_name}/${group_name}/listGroup`,
    method: 'post',
    data: data
  });
}

function listByIds(ids) {
  return fetch({
    url: `${api_name}/${group_name}/listByIds/${ids}`
  });
}
/**
 *导师管理批量指定
 */

function pointTutors(data) {
  return fetch({
    url: `${api_name}/${group_name_two}/batch`,
    method: 'post',
    data: data
  });
}

/**
 *导师指定
 */

function pointTutor(data) {
  return fetch({
    url: `${api_name}/${group_name_two}`,
    method: 'post',
    data: data
  });
}

/**
 *发布
 */

function releaseTutor(data) {
  return fetch({
    url: `${api_name}/${group_name_two}/release`,
    method: 'put',
    data: data
  });
}

/**
 *自动分配
 */

function autoAllocation(data) {
  return fetch({
    url: `${api_name}/${group_name_two}/auto`,
    method: 'put',
    data: data,
    showMask: false
  });
}

/**
 *学生人数统计
 */

function stuCount(data) {
  return fetch({
    url: `${api_name}/${group_name_two}/count`,
    method: 'put',
    data: data
  });
}

/**
 *自动分配获取加载状态
 */

function getStatuds(key) {
  return fetch({
    url: `${api_name}/${group_name_two}/result/${key}`,
    method: 'get'
  });
}

/**
 *导师申请
 */

function applyTutor(tutorId, type) {
  return fetch({
    url: `${api_name}/${group_name_two}/apply?tutorId=` + tutorId + '&type=' + type,
    method: 'get',
    showMask: false
  });
}

/**
 *我的导师
 */

function myTutor(type) {
  return fetch({
    url: `${api_name}/${group_name_two}/myTutor?type=` + type,
    method: 'get'
  });
}

/**
 *获取学生登陆信息是否有权限
 */

function getStuMessage(type) {
  return fetch({
    url: `${api_name}/${group_name_two}/user?type=` + type,
    method: 'get'
  });
}

/**
 *删除导师库
 */
function del(data) {
  return fetch({
    url: `${api_name}/${group_name}`,
    method: 'delete',
    data: data
  });
}

/**
 *删除导师学生关系
 */

function delTutor(data) {
  return fetch({
    url: `${api_name}/${group_name_two}`,
    method: 'delete',
    data: data
  });
}
/**
 * 获取导师指导记录开关信息
 */
function getGuidanceRecordsControl(data){
  return fetch({
    url: `${api_name}/tutorGuidanceRecordsControl/list`,
    method:'post',
    data:data
  });
}
/**
 * 设置导师指导记录开关
 * @param {*} data 
 */
function addGuidanceRecordsControl(data){
  return fetch({
    url: `${api_name}/tutorGuidanceRecordsControl`,
    method: 'post',
    data: data
  });
}
function deleteGuidanceRecordsControl(id){
  return fetch({
    url: `${api_name}/tutorGuidanceRecordsControl/deleteById/${id}`,
    method: 'get'   
  });
}
function getGuidanceRecordsControlById(id){
  return fetch({
    url: `${api_name}/tutorGuidanceRecordsControl/${id}`,
    method: 'get'
  });
}
function updateGuidanceRecordsControlById(data){
  return fetch({
    url: `${api_name}/tutorGuidanceRecordsControl`,
    method: 'put',
    data
  });
}

export default {
  findTutorListByVo: findTutorListByVo,
  findTeacherByCode: findTeacherByCode,
  addTutor: addTutor,
  editTutor: editTutor,
  findTutorById: findTutorById,
  findPicture: findPicture,
  findTutor: findTutor,
  pointTutors: pointTutors,
  pointTutor: pointTutor,
  releaseTutor: releaseTutor,
  autoAllocation: autoAllocation,
  stuCount: stuCount,
  getStatuds: getStatuds,
  applyTutor: applyTutor,
  myTutor: myTutor,
  getStuMessage: getStuMessage,
  del: del,
  delTutor: delTutor,
  findTutorGroup: findTutorGroup,
  listByIds: listByIds,
  getGuidanceRecordsControl:getGuidanceRecordsControl,
  addGuidanceRecordsControl:addGuidanceRecordsControl,
  deleteGuidanceRecordsControl:deleteGuidanceRecordsControl,
  getGuidanceRecordsControlById:getGuidanceRecordsControlById,
  updateGuidanceRecordsControlById:updateGuidanceRecordsControlById
}
